import type { MachineryModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 查询设备数据集合，包含产线和工位信息
 * @param params 查询参数
 * @returns 返回查询结果
 */
export async function getMachineryListApi(params?: any) {
  return requestClient.get<MachineryModel[]>('/mes/equipment/machinery/list', {
    params,
  });
}

/**
 * 分页查询设备数据集合
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getMachineryPagedListApi(params?: PageParams) {
  return requestClient.get<PaginationResult<MachineryModel>>(
    '/mes/equipment/machinery/list-page',
    {
      params,
    },
  );
}

/**
 * 创建设备
 * @param data 要创建的设备
 * @returns 返回结果
 */
export async function createMachineryApi(data: any) {
  return requestClient.post<boolean>('/mes/equipment/machinery', data);
}

/**
 * 更新设备
 * @param id 设备 Id
 * @param data 要更新的设备
 * @returns 返回结果
 */
export async function updateMachineryApi(id: number, data: any) {
  return requestClient.put<boolean>(`/mes/equipment/machinery/${id}`, data);
}

/**
 * 删除设备
 * @param id 设备 Id
 * @returns 返回结果
 */
export async function deleteMachineryApi(id: number) {
  return requestClient.delete<boolean>(`/mes/equipment/machinery/${id}`);
}
